if (!DOM) {
	var DOM = {};
}

DOM.XEvent = Object.extend({
	constructor : function(event) {
		
	}
});

DOM.XMouseEvent = DOM.XEvent.extend({
	constructor : function(event) {
		
	}
});

DOM.XKeyEvent = DOM.XEvent.extend({
	constructor : function(event) {
		
	}
});

DOM.addEventListener = function(node, type, eventHandler) {
	if (!node._eventListeners) {
		node._eventListeners = {};
	}
	if (!node._eventListeners[type]) {
		node._eventListeners[type] = [];
	}
	var eventListeners = node._eventListeners[type];
	for (var i = 0; i < eventListeners.length; i++) {
		if (eventListeners[i].eventHandler === eventHandler) {
			return;
		}
	}
	var xEventHandler = function(e) {
		if (!e) {
			e = window.event;
		}
		eventHandler.call(node, e);
	};
	if (node.addEventListener) {
		node.addEventListener(type, xEventHandler, false);
	} else if (node.attachEvent) {
		node.attachEvent("on" + type, xEventHandler);
	}
	eventListeners.push({
		eventHandler : eventHandler,
		xEventHandler : xEventHandler
	});
};

DOM.removeEventListener = function(node, type, eventHandler) {
	if (!node._eventListeners || !node._eventListeners[type]) {
		return;
	}
	var eventListeners = node._eventListeners[type];
	var xEventHandler;
	for (var i = 0; i < eventListeners.length; i++) {
		if (eventListeners[i].eventHandler === eventHandler) {
			xEventHandler = eventListeners[i].xEventHandler;
			if (node.removeEventListener) {
				node.removeEventListener(type, xEventHandler, false);
			} else if (node.detachEvent) {
				node.detachEvent("on" + type, xEventHandler);
			}
			eventListeners.splice(i, 1);
		}
	}
};
